﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace luceneindex
{
    class LucenePerformance
    {
        /*
        通过RAMDirectory缓写提高性能
        我们可以先把索引写入RAMDirectory，达到一定数量时再批量写进FSDirectory，减少磁盘IO次数。

        FSDirectory fsDir = FSDirectory.getDirectory("/data/index", true);
        RAMDirectory ramDir = new RAMDirectory();
        IndexWriter fsWriter = new IndexWriter(fsDir, new StandardAnalyzer(), true);
        IndexWriter ramWriter = new IndexWriter(ramDir, new StandardAnalyzer(), true);
        while (there are documents to index)
        {
            ... create Document ...
            ramWriter.addDocument(doc);
            if (condition for flushing memory to disk has been met)
            {
                fsWriter.addIndexes(new Directory[] { ramDir });
                ramWriter.close();
                ramWriter = new IndexWriter(ramDir, new StandardAnalyzer(), true);
            }
        }
         */
    }
}
